#ifndef __KEYBOARD_H
#define __KEYBOARD_H

#include <SDL/SDL.h>

#include "event.h"

/**
  * This class represents to the keyboard.
  * It's able to receive specific SDL_Events and to answer to a request of the
  * generic events. To do it, it uses an actual state and other old.
  * When a new event happens the actual state is updated, @see receiveEvent.
  * Then a request about the event or state can be do it,
  * @see isEventTriggered. Later the keyboard is update and the old and actual
  * state is the same.
  */
class Keyboard
{
	public:
    /**
      * Set all the keys to NO_PRESSED.
      */
		Keyboard();
    /**
      * Don't do really much.
      */
		~Keyboard();

    /** Update the old state to the actual*/
		void update();

    /**
      * Modify the actual state with the event.
      *
      * @param event is a SDL_Event get it of the event queue.
      */
    void receiveEvent(const SDL_Event &event);

    /**
      * Return if a event happened or not, and how many did it.
      *
      * @param event is the event is going to be checked.
      * @param magnitude is a write parameter to know "how many event" happened.
      * In keyboard always be 1 is the event happened.
      *
      * @returns true if the event happened.
      */
    bool isEventTriggered(const Event &event,Sint32 &magnitude);
	protected:
		/**
      * It's array each element is a key. It's the actual state.
      * If the position SDLK_a is true means key a has been pressed.
      */
		bool m_keys[SDLK_LAST];

		/** The same @see m_keys but save the old state */
		bool m_oldKeys[SDLK_LAST];
};

#endif
